package com.superdaxue.rxsampledemo.presenter;

import android.util.Log;

import com.superdaxue.rxsampledemo.bean.DataBean;
import com.superdaxue.rxsampledemo.model.ShowContentModel;
import com.superdaxue.rxsampledemo.model.onShowContentListener;
import com.superdaxue.rxsampledemo.view.ShowContentView;

/**
 * Created by ZX_CC on 2016/5/24.
 */

public class ShowContentPresenter {
    private ShowContentModel showContentModel;
    private ShowContentView showContentView;

    public ShowContentPresenter(ShowContentView showContentView) {
        this.showContentView = showContentView;
        showContentModel = new ShowContentModel();
    }

    public void getListData(int page){
        showContentModel.onResult(new onShowContentListener() {
            @Override
            public void onSuccess(DataBean dataBean) {
                showContentView.onShow(dataBean);
            }

            @Override
            public void onFailed(String string) {
                showContentView.onFailedMessage(string);
            }
        },page);
    }

    public void cancel(){
        showContentModel.cancelRequest();
    }

    public boolean getRefreshState(){
        return showContentModel.isState();
    }
}
